package com.example.mall.search.mapstruct;

import com.example.mall.search.mapstruct.dto.DoctorDto;
import com.example.mall.search.mapstruct.pojo.Doctor;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * 拷贝 Doctor 类中 List<Patient> patients 属性时，若 Patient 类中属性需要添加映射，则也需要为 Patient 类新建一个 PatientMapper
 * 此时 Doctor 类再进行拷贝 List<Patient> patients属性时，则需要使用 uses = {PatientMapper.class}
 * 否则就算在 PatientMapper 中添加了映射也还是无法拷贝属性值
 */
@Mapper(uses = {PatientMapper.class})
public interface DoctorMapper {

    DoctorMapper INSTANCE = Mappers.getMapper(DoctorMapper.class);

    @Mapping(source = "doctor.desc", target = "remark")
    @Mapping(source = "doctor.patients", target = "patientDtos")
    DoctorDto doctorToDoctorDto(Doctor doctor);
}
